************************************************************************************************************************
*REPLICATE RESULTS FOR PAPER "Farmer Field Days and Demonstrator Selection for Increasing Technology Adoption"
************************************************************************************************************************
clear all
set more off, permanently
*change the line below to directory where clean data are
cd ""
*change the line below to directory where figures and tables to be written
global latex ""

***********************************************************************
*SUMMARY STATISTICS AND BALANCE TESTS: TABLES A2 AND A3
***********************************************************************
use year1infosurvey, clear
*set aside p values to adjust for clustering 
mat p=J(1,17,0) /*set up matrix for result report*/
mat p2=J(1,17,0)
foreach k in 1 2 3 4 5 { 
mat c`k'=J(1,17,0)
}
loc k=1
foreach i in electricity mudwalls thatchroof nrooms educ_farm kharifarea privatetube cowown adoptswarna shg_hh has_mobile bplcard jobcard storsc hastv hasmobike refrig {
xi: reg `i' fieldday i.block, vce(cl village_id)
test fieldday 
mat p[1,`k']=r(p) 
sum `i' if fieldday==0 
mat c1[1,`k']=r(mean)
sum `i' if fieldday==1
mat c2[1,`k']=r(mean)
loc k = `k'+1 /*add to counter*/
}

foreach i in p p2 c1 c2 c3 c4 c5 { 
matrix colnames `i' = electricity mudwalls thatchroof nrooms educ_farm kharifarea privatetube cowown adoptswarna shg_hh has_mobile bplcard jobcard storsc hastv hasmobike refrig
} /*save matrix's column names*/

*column 1
estpost ttest electricity mudwalls thatchroof nrooms educ_farm kharifarea privatetube cowown adoptswarna shg_hh has_mobile bplcard jobcard storsc hastv hasmobike refrig, by(fieldday)
matrix rename c1 kyl, replace
estadd matrix kyl, replace /*overwrite existing e(p)*/ 
estimates store col1

*column 2
estpost ttest electricity mudwalls thatchroof nrooms educ_farm kharifarea privatetube cowown adoptswarna shg_hh has_mobile bplcard jobcard storsc hastv hasmobike refrig, by(fieldday)
matrix rename c2 kyl, replace
estadd matrix kyl, replace /*overwrite existing e(p)*/ 
estimates store col2

*column 3
estpost ttest electricity mudwalls thatchroof nrooms educ_farm kharifarea privatetube cowown adoptswarna shg_hh has_mobile bplcard jobcard storsc hastv hasmobike refrig, by(fieldday)
matrix rename p kyl, replace
estadd matrix kyl, replace /*overwrite existing e(p)*/ 
estimates store col3

*make table 
esttab col1 col2 col3 using "${latex}tablea2.tex", cells("kyl(fmt(3)) ") ///
notes replace noobs mlabels("No Field Day" "Field Day" "p-value") ///
nonumbers collabels(,none) label alignment(ccc) gaps width(\hsize) wrap ///
mgroups("\multicolumn{2}{c}{Means} \\ \cline{2-3} ", pattern(1 1 0))

*balance of characteristics by different types of demonstrator treatment
loc k=1
foreach i in electricity mudwalls thatchroof nrooms educ_farm kharifarea privatetube cowown adoptswarna shg_hh has_mobile bplcard jobcard storsc hastv hasmobike refrig {
xi: reg `i' shg_village meet_village i.block, vce(cl village_id)
test shg_village meet_village 
mat p2[1,`k']=r(p) 
sum `i' if shg_village==1
mat c3[1,`k']=r(mean)
sum `i' if meet_village==1
mat c4[1,`k']=r(mean)
sum `i' if ward_village==1
mat c5[1,`k']=r(mean)
loc k = `k'+1 /*add to counter*/
}

foreach j in p2 c3 c4 c5 { 
estpost ttest electricity mudwalls thatchroof nrooms educ_farm kharifarea privatetube cowown adoptswarna shg_hh has_mobile bplcard jobcard storsc hastv hasmobike refrig, by(fieldday)
matrix rename `j' kyl, replace
estadd matrix kyl, replace 
estimates store `j'
}

esttab c5 c3 c4 p2 using "${latex}tablea3.tex", cells("kyl(fmt(3)) ") ///
notes replace noobs mlabels("Ward Member" "SHG Meeting" "Village Meeting" " Joint p-value") ///
nonumbers collabels(,none) label alignment(cccc) gaps width(\hsize) wrap ///
mgroups("\multicolumn{3}{c}{Means} \\ \cline{2-4} ", pattern(1 1 1 0))

********************************************************************************
*TABLE 1: Effects of field days on knowledge
********************************************************************************
use year1infosurvey, clear

*loop to run regressions for multiple choice questions on swarna-sub1 properties
foreach i in  know_ss1 ss1talk cor_trivia1 cor_trivia2 cor_trivia3 cor_trivia5 cor_trivia6 cor_trivia10 score { 
xi: reg `i' fieldday shg_village meet_village i.block, vce(cl village_id) 
test shg_village=meet_village
estadd sca pval = r(p)
sum `i' if ward_village==1 & e(sample)==1
estadd sca ym = r(mean)
estimates store tri_`i'
}

*make table 
esttab tri_ss1talk tri_know_ss1 tri_cor_trivia1 tri_cor_trivia2 tri_cor_trivia3 tri_cor_trivia5 tri_cor_trivia6 tri_cor_trivia10 tri_score  using "${latex}table1.tex", ///
replace b(%10.3f) se wrap star(* 0.10 ** 0.05 *** 0.01) noobs label ///
scalars("pval p-value Village=SHG" "ym Mean in Ward villages" "N Number of Observations" "r2 R squared") sfmt(%10.2f %10.3f %10.0f %10.3f) ///
mtitles("Number adopters talked to" "Ever heard of" "Difference with Swarna" "Pesticide requirement" "Available at Block" "Max survival when flooded" "Most suitable land type" "Length of growing cycle" "sum 3-8") ///
align(cccccccc) width(\hsize) nonotes gaps drop(_Ibl* _cons) order(fieldday meet_village shg_village)

***************************************************************************************************************
*TABLE 2: Effects of village selection of demonstrators and field days on technology adoption
***************************************************************************************************************
use seedsales, clear 

*columns 1-3, no controls
xi: reg buy fieldday shg_village meet_village i.census_tahsil, vce(cl village_id) /*regression for whether the farmer purchased Swarna-Sub1 when given a sales offer*/
estadd ysumm 
sum buy if fieldday==0 & e(sample)==1 /*save mean of dependent variable in non-field day villages*/
estadd sca ym = r(mean)
sum buy if ward_village==1 & e(sample)==1 /*save mean of dependent variable in ward villages*/
estadd sca yward = r(mean)
estimates store b1

xi: reg buy5 fieldday shg_village meet_village i.census_tahsil, vce(cl village_id)  /*regression for purchasing of 1 seed package (5 kg)*/
estadd ysumm 
sum buy5 if fieldday==0 & e(sample)==1 /*save mean of dependent variable in non-field day villages*/
estadd sca ym = r(mean)
sum buy5 if ward_village==1 & e(sample)==1 /*save mean of dependent variable in ward villages*/
estadd sca yward = r(mean)
estimates store b2

xi: reg buy10 fieldday shg_village meet_village i.census_tahsil, vce(cl village_id) /*regression for purchasing of 2 or more seed packages (10 kg or more)*/
estadd ysumm 
sum buy10 if fieldday==0 & e(sample)==1/*save mean of dependent variable in non-field day villages*/
estadd sca ym = r(mean)
sum buy10 if ward_village==1 & e(sample)==1 /*save mean of dependent variable in ward villages*/
estadd sca yward = r(mean)
estimates store b3

*columns 4-6 controls
egen totarea_14 = rowtotal(area14_*) /*generate control variable for cultivated area*/

xi: reg buy fieldday shg_village meet_village storsc bplcard jobcard totarea_14 thatchroof mudwalls educ_farm age_farm elevation shg_hh privatetube adoptswarna i.census_tahsil, vce(cl village_id)
estadd ysumm  /*regression adding household controls,regression for whether the farmer purchased Swarna-Sub1 when given a sales offer*/
sum buy if fieldday==0 & e(sample)==1
estadd sca ym = r(mean)
sum buy if ward_village==1 & e(sample)==1 /*save mean of dependent variable in ward villages*/
estadd sca yward = r(mean)
estimates store b4
xi: reg buy5 fieldday shg_village meet_village storsc bplcard jobcard totarea_14 thatchroof mudwalls educ_farm age_farm elevation shg_hh privatetube adoptswarna i.census_tahsil, vce(cl village_id)
estadd ysumm /*regression adding household controls,regression for purchasing of 1 seed package (5 kg)*/
sum buy5 if fieldday==0 & e(sample)==1
estadd sca ym = r(mean)
sum buy5 if ward_village==1 & e(sample)==1 /*save mean of dependent variable in ward villages*/
estadd sca yward = r(mean)
estimates store b5
xi: reg buy10 fieldday shg_village meet_village storsc bplcard jobcard totarea_14 thatchroof mudwalls educ_farm age_farm elevation shg_hh privatetube adoptswarna i.census_tahsil, vce(cl village_id)
estadd ysumm /*regression adding household controls,regression for purchasing of 2 or more seed packages (10 kg or more)*/
sum buy10 if fieldday==0 & e(sample)==1
estadd sca ym = r(mean)
sum buy10 if ward_village==1 & e(sample)==1 /*save mean of dependent variable in ward villages*/
estadd sca yward = r(mean)
estimates store b6

*make table 
esttab b1 b2 b3 b4 b5 b6 using "${latex}table2.tex", ///
replace b(%10.3f) se wrap star(* 0.10 ** 0.05 *** 0.01) noobs label ///
scalars("ym Mean in non-field day villages" "yward Mean in Ward villages" "N Number of Observations" "r2 R squared") sfmt(%10.3f %10.3f %10.0f %10.3f) ///
mtitles("Buy" "Buy 5 KG" "Buy 10 KG" "Buy" "Buy 5 KG" "Buy 10 KG") align(cccccc) width(\hsize) nonotes gaps drop(_cons) order(meet_village shg_village fieldday) ///
indicate("HH Controls = storsc bplcard jobcard totarea_14 thatchroof mudwalls educ_farm age_farm elevation shg_hh privatetube adoptswarna" "Strata FE = _Icen*")

***************************************************************************************************************
*TABLE 3: Interaction effects between farmer field days and meetings
***************************************************************************************************************
use seedsales, clear  
gen field_shg = shg_village*fieldday  /*interaction between field days and shg village*/
gen field_meet = meet_village*fieldday /*interaction between field days and meet villages */
label var field_shg "Field day * SHG meeting" 
label var field_meet "Field day * Village meeting" 

xi: reg buy fieldday field_shg field_meet shg_village meet_village i.census_tahsil, vce(cl village_id)
estadd ysumm 
sum buy if fieldday==0 & e(sample)==1
estadd sca ym = r(mean)
sum buy if ward_village==1 & e(sample)==1 /*save mean of dependent variable in ward villages*/
estadd sca yward = r(mean)
estimates store c1

xi: reg buy5 fieldday field_shg field_meet  shg_village meet_village i.census_tahsil, vce(cl village_id)
estadd ysumm 
sum buy5 if fieldday==0 & e(sample)==1
estadd sca ym = r(mean)
sum buy5 if ward_village==1 & e(sample)==1 /*save mean of dependent variable in ward villages*/
estadd sca yward = r(mean)
estimates store c2

xi: reg buy10 fieldday field_shg field_meet  shg_village meet_village i.census_tahsil, vce(cl village_id)
estadd ysumm 
sum buy10 if fieldday==0 & e(sample)==1
estadd sca ym = r(mean)
sum buy10 if ward_village==1 & e(sample)==1 /*save mean of dependent variable in ward villages*/
estadd sca yward = r(mean)
estimates store c3

*with controls
egen totarea_14 = rowtotal(area14_*) /*generate control variable for cultivated area*/

xi: reg buy fieldday field_shg field_meet  shg_village meet_village storsc bplcard jobcard totarea_14 thatchroof mudwalls educ_farm age_farm elevation shg_hh privatetube adoptswarna i.census_tahsil, vce(cl village_id)
estadd ysumm /*regression include interaction effects between field days and meetings, with HH controls*/
sum buy if fieldday==0 & e(sample)==1
estadd sca ym = r(mean)
sum buy if ward_village==1 & e(sample)==1 /*save mean of dependent variable in ward villages*/
estadd sca yward = r(mean)
estimates store c4

xi: reg buy5 fieldday field_shg field_meet shg_village meet_village storsc bplcard jobcard totarea_14 thatchroof mudwalls educ_farm age_farm elevation shg_hh privatetube adoptswarna i.census_tahsil, vce(cl village_id)
estadd ysumm 
sum buy5 if fieldday==0 & e(sample)==1
estadd sca ym = r(mean)
sum buy5 if ward_village==1 & e(sample)==1 /*save mean of dependent variable in ward villages*/
estadd sca yward = r(mean)
estimates store c5

xi: reg buy10 fieldday field_shg field_meet  shg_village meet_village storsc bplcard jobcard totarea_14 thatchroof mudwalls educ_farm age_farm elevation shg_hh privatetube adoptswarna i.census_tahsil, vce(cl village_id)
estadd ysumm 
sum buy10 if fieldday==0 & e(sample)==1
estadd sca ym = r(mean)
sum buy10 if ward_village==1 & e(sample)==1 /*save mean of dependent variable in ward villages*/
estadd sca yward = r(mean)
estimates store c6

*make table
esttab c1 c2 c3 c4 c5 c6 using "${latex}table3.tex", ///
replace b(%10.3f) se wrap star(* 0.10 ** 0.05 *** 0.01) noobs label ///
scalars("ym Mean in non-field day villages" "yward Mean in Ward villages" "N Number of Observations" "r2 R squared") sfmt(%10.3f %10.3f %10.0f %10.3f) ///
mtitles("Buy" "Buy 5 KG" "Buy 10 KG" "Buy" "Buy 5 KG" "Buy 10 KG") align(cccccc) width(\hsize) nonotes gaps drop(_cons) ///
indicate("HH Controls = storsc bplcard jobcard totarea_14 thatchroof mudwalls educ_farm age_farm elevation shg_hh privatetube adoptswarna" "Strata FE = _Icen*")

***************************************************************************************************************
*TABLE 4: Effects estimated for the entire village
***************************************************************************************************************
use adoption_census.dta, clear
gen field_shg = fieldday*shg_village 
gen field_meet = fieldday*meet_village
label var field_shg "Field day * SHG meeting" 
label var field_meet "Field day * Village meeting" 

xi: reg adopter fieldday shg_village meet_village i.census_tahsil, vce(cl village_id) /*for entire population*/
sum adopter if fieldday==0 & e(sample)==1
estadd sca ym = r(mean)
sum adopter if ward_village==1 & e(sample)==1
estadd sca yward = r(mean)
estimates store c3

xi: reg adopter fieldday shg_village meet_village field_shg field_meet i.census_tahsil, vce(cl village_id) /*same regression, adding interaction term of meeting and field days*/
sum adopter if fieldday==0 & e(sample)==1
estadd sca ym = r(mean)
sum adopter if ward_village==1 & e(sample)==1
estadd sca yward = r(mean)
estimates store c4

xi: reg num_variety_2015 fieldday shg_village meet_village i.census_tahsil if adopter!=., vce(cl village_id) /*for entire population*/
sum num_variety_2015 if fieldday==0 & e(sample)==1
estadd sca ym = r(mean)
sum num_variety_2015 if ward_village==1 & e(sample)==1
estadd sca yward = r(mean)
estimates store c7

gen nonss1_var_2015 = num_variety_2015 - adopter
xi: reg nonss1_var_2015 fieldday shg_village meet_village i.census_tahsil if adopter!=., vce(cl village_id) /*for entire population*/
sum nonss1_var_2015 if fieldday==0 & e(sample)==1
estadd sca ym = r(mean)
sum nonss1_var_2015 if ward_village==1 & e(sample)==1
estadd sca yward = r(mean)
estimates store c8

esttab c3 c4 c7 c8 using "${latex}table4.tex", ///
replace b(%10.3f) se wrap star(* 0.10 ** 0.05 *** 0.01) noobs label ///
scalars("ym Mean in non-field day villages" "yward Mean in Ward villages" "N Number of Observations" "r2 R squared") sfmt(%10.3f %10.3f %10.0f %10.3f) ///
mtitles("Adoption" "Adoption" "Number Varieties" "Number Non-SS1 varieties")  order(meet_village shg_village fieldday) nonotes gaps drop(_cons) indicate("Strata FE = _Icen*")


***************************************************************************************************************
*TABLE 5: Differential effects of field days as functions of caste and poverty status
***************************************************************************************************************
use seedsales, clear
egen totarea_14 = rowtotal(area14_*) /*generate control variable for cultivated area*/  
gen field_storsc = fieldday*storsc /*generate interaction term for caste of ST or SC with field day*/
gen field_bplcard = fieldday*bplcard  /*generate interaction term for bpl card with field day*/
label var field_bplcard "Field day * BPL card" 
label var field_storsc "Field day * ST or SC" 

xi: reg buy fieldday field_storsc shg_village meet_village storsc bplcard jobcard totarea_14 thatchroof mudwalls educ_farm age_farm elevation shg_hh privatetube adoptswarna i.census_tahsil, vce(cl village_id)
estadd ysumm 
sum buy if fieldday==0 & e(sample)==1
estadd sca ym = r(mean)
sum buy if ward_village==1 & e(sample)==1 /*save mean of dependent variable in ward villages*/
estadd sca yward = r(mean)
estimates store b_caste

xi: reg buy5 fieldday field_storsc shg_village meet_village storsc bplcard jobcard totarea_14 thatchroof mudwalls educ_farm age_farm elevation shg_hh privatetube adoptswarna i.census_tahsil, vce(cl village_id)
estadd ysumm 
sum buy5 if fieldday==0 & e(sample)==1
estadd sca ym = r(mean)
sum buy5 if ward_village==1 & e(sample)==1 /*save mean of dependent variable in ward villages*/
estadd sca yward = r(mean)
estimates store b5_caste

xi: reg buy10 fieldday field_storsc shg_village meet_village storsc bplcard jobcard totarea_14 thatchroof mudwalls educ_farm age_farm elevation shg_hh privatetube adoptswarna i.census_tahsil, vce(cl village_id)
estadd ysumm 
sum buy10 if fieldday==0 & e(sample)==1
estadd sca ym = r(mean)
sum buy10 if ward_village==1 & e(sample)==1 /*save mean of dependent variable in ward villages*/
estadd sca yward = r(mean)
estimates store b10_caste

xi: reg buy fieldday field_bplcard shg_village meet_village storsc bplcard jobcard totarea_14 thatchroof mudwalls educ_farm age_farm elevation shg_hh privatetube adoptswarna i.census_tahsil, vce(cl village_id)
estadd ysumm 
sum buy if fieldday==0 & e(sample)==1
estadd sca ym = r(mean)
sum buy if ward_village==1 & e(sample)==1 /*save mean of dependent variable in ward villages*/
estadd sca yward = r(mean)
estimates store b_bpl

xi: reg buy5 fieldday field_bplcard shg_village meet_village storsc bplcard jobcard totarea_14 thatchroof mudwalls educ_farm age_farm elevation shg_hh privatetube adoptswarna i.census_tahsil, vce(cl village_id)
estadd ysumm 
sum buy5 if fieldday==0 & e(sample)==1
estadd sca ym = r(mean)
sum buy5 if ward_village==1 & e(sample)==1 /*save mean of dependent variable in ward villages*/
estadd sca yward = r(mean)
estimates store b5_bpl

xi: reg buy10 fieldday field_bplcard shg_village meet_village storsc bplcard jobcard totarea_14 thatchroof mudwalls educ_farm age_farm elevation shg_hh privatetube adoptswarna i.census_tahsil, vce(cl village_id)
estadd ysumm 
sum buy10 if fieldday==0 & e(sample)==1
estadd sca ym = r(mean)
sum buy10 if ward_village==1 & e(sample)==1 /*save mean of dependent variable in ward villages*/
estadd sca yward = r(mean)
estimates store b10_bpl

esttab b_caste b5_caste b10_caste b_bpl b5_bpl b10_bpl using "${latex}table5.tex", ///
replace b(%10.3f) se wrap star(* 0.10 ** 0.05 *** 0.01) noobs label ///
scalars("ym Mean in non-field day villages" "yward Mean in Ward villages" "N Number of Observations" "r2 R squared") sfmt(%10.3f %10.3f %10.0f %10.3f) order(fieldday field_storsc field_bplcard) ///
mtitles("Buy" "Buy 5 KG" "Buy 10 KG" "Buy" "Buy 5 KG" "Buy 10 KG") align(cccccc) width(\hsize) nonotes gaps drop(_cons) ///
indicate("HH Controls = storsc bplcard jobcard totarea_14 thatchroof mudwalls educ_farm age_farm elevation shg_hh privatetube adoptswarna" "Strata FE = _Icen*")

***************************************************************************************************************
*TABLE 7: Effects of field days on adoption of demonstrators during the 2015 season
***************************************************************************************************************
use adoption_census.dta, clear

xi: reg adopter fieldday i.census_tahsil if demonstrator==1, vce(cl village_id) /*for entire population*/
sum adopter if fieldday==0 & e(sample)==1
estadd sca ym = r(mean)
sum adopter if ward_village==1 & e(sample)==1
estadd sca yward = r(mean)
estimates store c1_demo

xi: reg adopter fieldday shg_village meet_village i.census_tahsil if demonstrator==1, vce(cl village_id) /*same regression, adding interaction term of meeting and field days*/
sum adopter if fieldday==0 & e(sample)==1
estadd sca ym = r(mean)
sum adopter if ward_village==1 & e(sample)==1
estadd sca yward = r(mean)
estimates store c2_demo

esttab c1_demo c2_demo using "${latex}table7.tex", ///
replace b(%10.3f) se wrap star(* 0.10 ** 0.05 *** 0.01) noobs label ///
scalars("ym Mean in non-field day villages" "N Number of Observations" "r2 R squared") sfmt(%10.3f %10.0f %10.3f) ///
nomtitles order(fieldday shg_village meet_village) nonotes gaps drop(_cons) indicate("Strata FE = _Icen*")

***************************************************************************************************************
*TABLE A1: Correlates of farmer field day attendance
***************************************************************************************************************
use year1infosurvey, clear
gen att_fd = (fdaygo==1) /*generate dummy for attending the field day */
egen land14 = rowtotal(area14*) /*generate land14 for all the areas cultivated in 2014*/
replace land14 = . if land14 > 15 /*really high values*/
label var land14 "Rice area" 

xi: reg att_fd shg_village meet_village i.block if fieldday==1, vce(cl village_id) /*regress the indicator of attending the field day when it took place*/
test shg_village=meet_village /*ttest coefficients of shg and meeting*/
estadd sca pval = r(p) /*save the p value*/
sum att_fd if ward_village==1 & e(sample)==1 /*sum the mean of attendance in ward village*/
estadd sca ym = r(mean)
estimates store attend1

xi: reg att_fd shg_village meet_village storsc shg_hh age_farm educ_farm bplcard land14 i.block if fieldday==1, vce(cl village_id)/*add control variables in the regresssion of the indicator of attending the field day when it took place*/
test shg_village=meet_village
estadd sca pval = r(p)
sum att_fd if ward_village==1 & e(sample)==1
estadd sca ym = r(mean)
estimates store attend2

foreach k in shg_hh storsc age_farm educ_farm bplcard land14 { 
gen `k'_interact = `k'*shg_village  
}
xi: reg att_fd shg_village shg_hh storsc age_farm educ_farm bplcard land14 *interact i.block if fieldday==1, vce(cl village_id)
sum att_fd if ward_village==1 & e(sample)==1
estadd sca ym = r(mean)
estimates store attend3

foreach k in shg_hh storsc age_farm educ_farm bplcard land14 { 
drop `k'_interact
gen `k'_interact = `k'*meet_village
}
xi: reg att_fd meet_village shg_hh storsc age_farm educ_farm bplcard land14 *interact i.block if fieldday==1, vce(cl village_id)
sum att_fd if ward_village==1 & e(sample)==1
estadd sca ym = r(mean)
estimates store attend4

foreach x in shg_hh storsc age_farm educ_farm bplcard land14 { 
local lb: variable label `x' 
label variable `x'_interact `"`lb'"'
}

esttab attend1 attend2 attend3 attend4 using "${latex}tablea1.tex", ///
replace b(%10.3f) se wrap star(* 0.10 ** 0.05 *** 0.01) noobs label ///
scalars("pval p-value Village=SHG" "ym Mean in Ward villages" "N Number of Observations" "r2 R squared") sfmt(%10.2f %10.3f %10.0f %10.3f) ///
mtitles("" "" "SHG" "Meeting") align(cc) width(\hsize) nonotes gaps drop(_cons) indicate("Strata FE = _Ibl*") ///
refcat(shg_hh_interact "\underline{\emph{Interaction with:}}", nolabel) ///
mgroups("&&\multicolumn{2}{c}{Interactions:} \\ \cline{4-5} ", pattern(0 0 1 0))

***************************************************************************************************************
*TABLE A4: Characteristics of demonstrators
***************************************************************************************************************
use demonstrators_characteristics, clear

local models ward_conn pri shg_hh shgpres_conn leader coop storsc educ_farm age_farm areacult mudwalls hasbpl cowown sharecropper dspanvalue
/*local all the dependent variables as models*/
forvalues i=1(1)3 { 
mat b`i' = J(1,15,0)
mat s`i' = J(1,15,0)
}/*set up matrix for result report*/
mat b4 = J(1,15,0)
loc j=0
foreach i of local models { 
loc j=`j'+1
xi: reg `i' meet_village shg_village, vce(cl village_id)
mat b1[1,`j']=_b[meet_village] /*save coefficient of village meeting*/
mat s1[1,`j']=_se[meet_village] /*save standard error of village meeting*/
mat b2[1,`j']=_b[shg_village]  /*save coefficient of shg village*/
mat s2[1,`j']=_se[shg_village]  /*save standard error of shg village*/
mat b3[1,`j']=_b[_cons] /*save constant term*/
mat s3[1,`j']= _se[_cons] /*standard error of constant term*/
test meet_village = shg_village /*test whether the coefficient of village meeting and shg village are the same*/
mat b4[1,`j'] = r(p) /*save ttest's p-value*/
}
foreach i in 1 2 3 { 
mat b = b`i'
mat se = s`i'
matrix colnames b = `models'
matrix colnames se = `models'
ereturn post b 
estadd matrix se
eststo mod`i'  /*store results of regressions(coefficients and standard error) in mod1-mod3*/
}
mat b=b4
matrix colnames b = `models'
ereturn post b 
eststo mod4 /*store results of ttests in mod4*/

esttab mod3 mod1 mod2 mod4 using "${latex}tablea4.tex", ///
replace b(%10.3f) se wrap star(* 0.10 ** 0.05 *** 0.01) noobs label mtitles("Ward Mean" "Village meeting" "SHG meeting" "p-value (2)-(3)") ///
align(ccc) width(\hsize) nonotes gaps  ///
mgroups(" & \multicolumn{2}{c}{Coefficients and SE:} & \\ \cline{3-4} ", pattern(0 1 1 0))

***************************************************************************************************************
*TABLE A5: Characteristics of demonstration across treatments
***************************************************************************************************************
use demonstrators_characteristics, clear

*characteristics at village level 
gen adopter = 1
gen suc_adopter = sub1acre>0 & sub1acre!=.  /*generate successful adopters whose Swarna Sub1 planted area is not 0 or null */
gen total_loss = (sub1acre==0) 
collapse (sum) adopter sub1kg sub1acre suc_adopter total_loss, by(village_id group census_tahsil meet_village shg_village ward_village) /*collapse data at village level*/

*regressions
xi: reg adopter meet_village shg_village, vce(robust) /*regress number of adopters in 2014 in each village on treatments of village meeting and shg villages*/
test meet_village=shg_village /*test whether the coefficients of meeting and shg treatments are the same*/
estadd sca pval = r(p) /*save the p-value in scalar pval*/
sum adopter if ward_village==1 /*sum 2014 adopter number in ward villages*/
estadd sca ym = r(mean) /*save the mean of 2014 adopter number in ward villages in scalar ym*/
estimates store adopter /*store result in adopter*/

gen mt5 = (adopter > 5)
xi: reg mt5 meet_village shg_village, vce(robust) 
test meet_village=shg_village /*test whether the coefficients of meeting and shg treatments are the same*/
estadd sca pval = r(p) /*save the p-value in scalar pval*/
sum mt5 if ward_village==1 /*sum 2014 adopter number in ward villages*/
estadd sca ym = r(mean) /*save the mean of 2014 adopter number in ward villages in scalar ym*/
estimates store adoptm5 /*store result in adopter*/
	
xi: reg sub1acre meet_village shg_village, vce(robust) /*regress the total acres planted in 2014 in each village on treatments of village meeting and shg villages*/
test meet_village=shg_village 
estadd sca pval = r(p)
sum sub1acre if ward_village==1
estadd sca ym = r(mean)
estimates store sub1acre

xi: reg sub1kg meet_village shg_village, vce(robust) /*regress  the total kg planted in 2014 in each village on treatments of village meeting and shg villages*/
test meet_village=shg_village
estadd sca pval = r(p)
sum sub1kg if ward_village==1
estadd sca ym = r(mean)
estimates store sub1kg

*make table
esttab sub1kg adopter adoptm5 sub1acre using "${latex}tablea5.tex", ///
replace b(%10.3f) se wrap scalars("pval p-value Village=SHG" "ym Mean in Ward member villages" "N Number of Observations" "r2 R squared") sfmt(%10.2f %10.2f %10.0f %10.3f) ///
star(* 0.10 ** 0.05 *** 0.01) noobs label mtitles("KG planted" "N demonstrators" "More than 5 demonstrators" "Acres transplanted") ///
drop(_cons) align(cccc) width(\hsize) nonotes

***************************************************************************************************************
*TABLE A6: Predictors of planting Swarna-Sub1 amongst demonstrators
***************************************************************************************************************
use demonstrators_characteristics, clear
gen suc_adopter = sub1acre>0 & sub1acre!=.  /*generate successful adopters whose Swarna Sub1 planted area is not 0 or null */

*regressions of transplanting Swarna-Sub1 on covariates
xi: reg suc_adopter meet_village shg_village fieldday i.block, vce(cl village_id)
test meet_village=shg_village 
estadd sca pval = r(p)
sum suc_adopter if ward_village==1
estadd sca ym = r(mean)
estimates store adopt_bal 

xi: reg suc_adopter meet_village shg_village fieldday ward_conn pri shg_hh leader coop storsc educ_farm age_farm areacult mud hasbpl cowown sharecropper dspanvalue i.block, vce(cl village_id)
test meet_village=shg_village 
estadd sca pval = r(p)
sum suc_adopter if ward_village==1
estadd sca ym = r(mean)
estimates store adopt_bal_covariates 

*make table
esttab adopt_bal adopt_bal_covariates using "${latex}tablea6.tex", ///
replace b(%10.3f) se scalars("pval p-value Village=SHG" "ym Mean in Ward member villages" "N Number of Observations" "r2 R squared") sfmt(%10.2f %10.2f %10.0f %10.3f) ///
star(* 0.10 ** 0.05 *** 0.01) noobs label nomtitles drop(_cons _Iblo*) align(cc) nonotes

*****************************************************************************************************************************
*TABLE A7: Effects of field days on knowledge, by attendance 
*and Table A8 Field days and conversations about Swarna-Sub1
*****************************************************************************************************************************
use year1infosurvey, clear
*create field day attendance indicator for treatment villages
gen att_fd = (fdaygo==1) /*generate dummy for attending the field day */

*trivia question, by field day attendance 
gen fd_andgo = (fieldday==1 & att_fd==1)
gen fd_nogo = (fieldday==1 & att_fd==0)
label var fd_andgo "Attended Field day" 
label var fd_nogo "Did not attend Field day"
foreach i in  talk_demo talk_nondemo know_ss1 ss1talk cor_trivia1 cor_trivia2 cor_trivia3 cor_trivia5 cor_trivia6 cor_trivia10 score { 
xi: reg `i' fd_andgo fd_nogo shg_village meet_village i.block, vce(cl village_id) 
test fd_andgo = fd_nogo
estadd sca pval = r(p)
sum `i' if ward_village==1 & e(sample)==1
estadd sca ym = r(mean)
estimates store tri_attend_`i'
}

*make tables 
esttab tri_attend_ss1talk tri_attend_know_ss1 tri_attend_cor_trivia1 tri_attend_cor_trivia2 tri_attend_cor_trivia3 tri_attend_cor_trivia5 tri_attend_cor_trivia6 tri_attend_cor_trivia10 tri_attend_score  using "${latex}tablea7.tex", ///
replace b(%10.3f) se wrap star(* 0.10 ** 0.05 *** 0.01) noobs label ///
scalars("pval p-value Attend=Non Attend" "ym Mean in Ward villages" "N Number of Observations" "r2 R squared") sfmt(%10.2f %10.3f %10.0f %10.3f) ///
mtitles("Number adopters talked to" "Ever heard of" "Difference with Swarna" "Pesticide requirement" "Available at Block" "Max survival when flooded" "Most suitable land type" "Length of growing cycle" "sum 3-8") ///
align(cccccccc) width(\hsize) nonotes gaps drop(_Ibl* _cons) order(fd_andgo fd_nogo meet_village shg_village)

esttab tri_attend_talk_demo tri_attend_talk_nondemo  using "${latex}tablea8.tex", ///
replace b(%10.3f) se wrap star(* 0.10 ** 0.05 *** 0.01) noobs label ///
scalars("pval p-value Attend=Non Attend" "ym Mean in Ward villages" "N Number of Observations" "r2 R squared") sfmt(%10.2f %10.3f %10.0f %10.3f) ///
mtitles("Demonstrators" "Others") align(cc) nonotes gaps drop(_Ibl* _cons) order(fd_andgo fd_nogo meet_village shg_village) ///
mgroups("\multicolumn{2}{c}{Conversations about Swarna-Sub1 with:} \\ \cline{2-3} ", pattern(1 0))

***************************************************************************************************************
*TABLE A9: Interaction effects when pooling two meeting types together
***************************************************************************************************************
use seedsales, clear 
gen field_any = fieldday*any_meet
label var field_any "Village or SHG meeting * Field day"

xi: reg buy fieldday any_meet field_any i.census_tahsil, vce(cl village_id) /*regression for whether the farmer purchased Swarna-Sub1 when given a sales offer*/
estadd ysumm 
sum buy if fieldday==0 & e(sample)==1 /*save mean of dependent variable in non-field day villages*/
estadd sca ym = r(mean)
sum buy if ward_village==1 & e(sample)==1 /*save mean of dependent variable in ward villages*/
estadd sca yward = r(mean)
estimates store b1pool

xi: reg buy5 fieldday any_meet field_any i.census_tahsil, vce(cl village_id)  /*regression for purchasing of 1 seed package (5 kg)*/
estadd ysumm 
sum buy5 if fieldday==0 & e(sample)==1 /*save mean of dependent variable in non-field day villages*/
estadd sca ym = r(mean)
sum buy5 if ward_village==1 & e(sample)==1 /*save mean of dependent variable in ward villages*/
estadd sca yward = r(mean)
estimates store b2pool

xi: reg buy10 fieldday any_meet field_any i.census_tahsil, vce(cl village_id) /*regression for purchasing of 2 or more seed packages (10 kg or more)*/
estadd ysumm 
sum buy10 if fieldday==0 & e(sample)==1/*save mean of dependent variable in non-field day villages*/
estadd sca ym = r(mean)
sum buy10 if ward_village==1 & e(sample)==1 /*save mean of dependent variable in ward villages*/
estadd sca yward = r(mean)
estimates store b3pool

*make table
esttab b1pool b2pool b3pool using "${latex}tablea9.tex", ///
replace b(%10.3f) se wrap star(* 0.10 ** 0.05 *** 0.01) noobs label ///
scalars("ym Mean in non-field day villages" "yward Mean in Ward villages" "N Number of Observations" "r2 R squared") sfmt(%10.3f %10.3f %10.0f %10.3f) ///
mtitles("Buy" "Buy 5 KG" "Buy 10 KG") align(ccc) width(\hsize) nonotes gaps drop(_cons) order(any_meet fieldday) ///
indicate("Strata FE = _Icen*")

***************************************************************************************************************
*TABLE A10: Heterogeneous effect of field days on knowledge by caste
*Table A11: Heterogeneous effect of field days on knowledge by BPL status
***************************************************************************************************************
use year1infosurvey, clear
gen field_storsc = fieldday*storsc
gen field_bpl = fieldday*bplcard
label var field_storsc "Field day * ST or SC"
label var bplcard "BPL Card" 
label var field_bpl "Field day * BPL Card" 
label var storsc "ST or SC"

foreach i in  know_ss1 ss1talk cor_trivia1  cor_trivia5 cor_trivia6 cor_trivia10 { 
xi: reg `i' fieldday field_storsc storsc i.block, vce(cl village_id) 
sum `i' if fieldday==0 & e(sample)==1
estadd sca ym = r(mean)
estimates store tri_`i'_schet

xi: reg `i' fieldday field_bpl bplcard i.block, vce(cl village_id) 
sum `i' if fieldday==0 & e(sample)==1
estadd sca ym = r(mean)
estimates store tri_`i'_bplhet
}

esttab tri_know_ss1_schet tri_ss1talk_schet tri_cor_trivia1_schet tri_cor_trivia5_schet tri_cor_trivia6_schet tri_cor_trivia10_schet  using "${latex}tablea10.tex", ///
replace b(%10.3f) se wrap star(* 0.10 ** 0.05 *** 0.01) noobs label ///
scalars("ym Mean in control villages" "N Number of Observations" "r2 R squared") sfmt(%10.3f %10.0f %10.3f) ///
mtitles("Ever heard of" "Number farmers talked to" "Diff w/ Swarna" "Maximum survival when flooded" "Most suitable land type" "Duration") ///
align(cccccc) width(\hsize) nonotes gaps drop(_Ibl* _cons) order(fieldday)

esttab tri_know_ss1_bplhet tri_ss1talk_bplhet tri_cor_trivia1_bplhet tri_cor_trivia5_bplhet tri_cor_trivia6_bplhet tri_cor_trivia10_bplhet  using "${latex}tablea11.tex", ///
replace b(%10.3f) se wrap star(* 0.10 ** 0.05 *** 0.01) noobs label ///
scalars("ym Mean in control villages" "N Number of Observations" "r2 R squared") sfmt(%10.3f %10.0f %10.3f) ///
mtitles("Ever heard of" "Number farmers talked to" "Diff w/ Swarna" "Maximum survival when flooded" "Most suitable land type" "Duration") ///
align(cccccc) width(\hsize) nonotes gaps drop(_Ibl* _cons) order(fieldday)

***************************************************************************************************************
*TABLE A12: Field day attendance by demonstrators across treatments
***************************************************************************************************************
use demonstrators_attendance, clear
*generate treatment variables
gen shg_village = (group=="SHG")
gen meet_village = (group=="VILLAGE MEETING")
gen ward_village = (group=="WARD MEMBER")
label var meet_village "Village meeting" 
label var ward_village "Ward member"
label var shg_village "SHG meeting"

*regressions
xi: reg dem_attend shg_village meet_village i.census_tahsil, vce(robust)
test meet_village=shg_village 
estadd sca pval = r(p)
estadd sca ym = r(mean)
sum dem_attend if ward_village==1 & e(sample)==1 /*save mean of dependent variable in ward villages*/
estadd sca yward = r(mean)
estimates store c1_demGO

xi: reg suc_attend shg_village meet_village i.census_tahsil, vce(robust)
test meet_village=shg_village 
estadd sca pval = r(p)
estadd sca ym = r(mean)
sum suc_attend if ward_village==1 & e(sample)==1 /*save mean of dependent variable in ward villages*/
estadd sca yward = r(mean)
estimates store c2_demGO

esttab c1_demGO c2_demGO using "${latex}tablea12.tex", ///
replace b(%10.3f) se wrap scalars("pval p-value Village=SHG" "yward Mean in Ward member villages" "N Number of Observations" "r2 R squared") sfmt(%10.2f %10.2f %10.0f %10.3f) ///
star(* 0.10 ** 0.05 *** 0.01) indicate("Strata FE = _Icen*") noobs label mtitles("Any" "Planting Swarna-Sub1") ///
drop(_cons) align(cc) nonotes

***************************************************************************************************************
*TABLE A13: Effect of field days for farmers not in door-to-door sample
***************************************************************************************************************
use adoption_census.dta, clear
gen field_shg = fieldday*shg_village 
gen field_meet = fieldday*meet_village
label var field_shg "Field day * SHG meeting" 
label var field_meet "Field day * Village meeting" 

xi: reg adopter fieldday shg_village meet_village i.census_tahsil if mkfarmer==0, vce(cl village_id) /*regression of indicator whether the farmer adopted Swarna-Sub1 for the 2015 season*/
sum adopter if fieldday==0 & e(sample)==1
estadd sca ym = r(mean)
sum adopter if ward_village==1 & e(sample)==1
estadd sca yward = r(mean)
estimates store c1

xi: reg adopter fieldday shg_village meet_village field_shg field_meet i.census_tahsil if mkfarmer==0, vce(cl village_id) /*same regression, adding interaction term of meeting and field days*/
sum adopter if fieldday==0 & e(sample)==1
estadd sca ym = r(mean)
sum adopter if ward_village==1 & e(sample)==1
estadd sca yward = r(mean)
estimates store c2

esttab c1 c2 using "${latex}tablea13.tex", ///
replace b(%10.3f) se wrap star(* 0.10 ** 0.05 *** 0.01) noobs label ///
scalars("ym Mean in non-field day villages" "yward Mean in Ward villages" "N Number of Observations" "r2 R squared") sfmt(%10.3f %10.3f %10.0f %10.3f) ///
nomtitles order(meet_village shg_village fieldday) nonotes gaps drop(_cons) indicate("Strata FE = _Icen*")

***************************************************************************************************************
*TABLE A14: Heterogeneous effect of field days by village-level exposure to flooding
***************************************************************************************************************
use seedsales, clear

*field days interacted with flood exposure 
gen field_flooded = fieldday*f500_dumT 
gen flooded = f500_dumT

xi: reg buy fieldday field_flooded flooded shg_village meet_village i.census_tahsil, vce(cl village_id)
estadd ysumm 
sum buy if fieldday==0 & e(sample)==1 /*save mean of dependent variable in non-field day villages*/
estadd sca ym = r(mean)
sum buy if ward_village==1 & e(sample)==1 /*save mean of dependent variable in ward villages*/
estadd sca yward = r(mean)
estimates store hte_500

drop flooded field_flooded
gen field_flooded = fieldday*f250_dumT 
gen flooded = f250_dumT
xi: reg buy fieldday field_flooded flooded shg_village meet_village i.census_tahsil, vce(cl village_id)
estadd ysumm 
sum buy if fieldday==0 & e(sample)==1 /*save mean of dependent variable in non-field day villages*/
estadd sca ym = r(mean)
sum buy if ward_village==1 & e(sample)==1 /*save mean of dependent variable in ward villages*/
estadd sca yward = r(mean)
estimates store hte_250

label var flooded "Flooded" 
label var field_flooded "Field day * Flooded"

esttab hte_250 hte_500 using "${latex}tablea14.tex", ///
replace b(%10.3f) se wrap star(* 0.10 ** 0.05 *** 0.01) noobs label ///
scalars("ym Mean in non-field day villages" "yward Mean in Ward villages" "N Number of Observations" "r2 R squared") sfmt(%10.3f %10.3f %10.0f %10.3f) order(fieldday) ///
mtitles("250 meters" "500 meters") align(cc) nonotes gaps drop(_cons) ///
indicate("Strata FE = _Icen*") mgroups("\multicolumn{2}{c}{Distance from flooding:} \\ \cline{2-3} ", pattern(1 0))

***************************************************************************************************************
*FIGURE 2: Distribution of village-level adoption rates by treatment
***************************************************************************************************************
use seedsales, clear
collapse (mean) buy, by(village_id fieldday) 
twoway (histogram buy if fieldday==1, fcolor(black) lcolor(black) bin(10) fraction barwidth(0.08)) /// 
(histogram buy if fieldday==0, fcolor(gs8) lcolor(gs8) bin(10) fraction barwidth(0.06)), scheme(s1color) ///
ytitle(Share of villages) xtitle(Village adoption rate) legend(label(1 "Field day") label(2 "No Field day"))
graph export "${latex}figure2.pdf", as(pdf) replace


***************************************************************************************************************
*FIGURE 3: Adoption rates separately for field day attendees and non-attendees
***************************************************************************************************************
use seedsales, clear
merge 1:1 unique_id using year1infosurvey, keepusing(unique_id fdaygo) /*merge in attendance*/
drop _merge
gen att_fd = (fdaygo==1) /*generate dummy for attending the field day */
replace att_fd=0 if fieldday==0
gen fday_attend = (att_fd==1 & fieldday==1) 
gen fday_non = (att_fd==0 & fieldday==1)

xi: reg buy fday_attend fday_non, vce(cl village_id) /*regression for whether the farmer purchased Swarna-Sub1 when given a sales offer*/
predict yhat, xb
predict seyhat, stdp
gen classgroup="control" 
replace classgroup="fday, attend" if fday_attend==1 
replace classgroup="fday, non" if fday_non==1
collapse (mean) yhat seyhat, by(classgroup)
sort yhat
gen ylow = yhat-1.96*seyhat 
gen yhigh = yhat+1.96*seyhat
gen xvar=_n
twoway (bar yhat xvar, barwidth(0.5) color(gs8)) (rspike ylow yhigh xvar, lcolor(black) lwidth(thick)), ///
scheme(s1color) ytitle("Adoption") ylabel(0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 0.45 0.5 0.55, grid) ///
xtitle("") xlabel(1 "Control" 2 "Treat, Non-attend" 3 "Treat, attend", valuelabel labsize(medium)) legend(off)
graph export "${latex}figure3.pdf", as(pdf) replace

***************************************************************************************************************
*FIGURE 4: Correlations between adoption, knowledge, number of demonstrators and number attending the field day
***************************************************************************************************************
*setting aside number of demonstrators that planted by village
use demonstrators_characteristics, clear
gen suc_adopter = sub1acre>0 & sub1acre!=.  /*generate successful adopters whose Swarna Sub1 planted area is not 0 or null */
collapse (sum) suc_adopter, by(village_id) /*collapse data at village level*/
tempfile vilfarm 
save "`vilfarm'", replace

*merging with seed sales and knowledge
use seedsales, clear
merge 1:1 unique_id using year1infosurvey, keepusing(unique_id score) /*merge in knowledge*/
drop _merge
merge n:1 village_id using demonstrators_attendance /*merge demonstrator attendance to field day*/
drop _merge
merge n:1 village_id using "`vilfarm'" 
drop _merge

*making graph
gen nobs=1
preserve 
collapse (mean) buy score (sum) nobs, by(fieldday suc_adopter) 
twoway (scatter buy suc_adopter if fieldday==1 [w=nobs], mcolor(black) msymbol(circle_hollow)) (scatter buy suc_adopter if fieldday==0 [w=nobs], mcolor(gs10) msymbol(circle_hollow)), ///
scheme(s1color) xtitle("Number demonstrators") ytitle("Adoption rate") legend(label(1 "Field day") label(2 "No Field day") pos(1) ring(0)) name(buy_tl, replace)
twoway (scatter score suc_adopter if fieldday==1 [w=nobs], mcolor(black) msymbol(circle_hollow)) (scatter score suc_adopter if fieldday==0 [w=nobs], mcolor(gs10) msymbol(circle_hollow)), ///
scheme(s1color) xtitle("Number demonstrators") ytitle("Knowledge score") legend(off) name(score_tr, replace)
restore 

preserve 
collapse (mean) buy score (sum) nobs, by(fieldday suc_attend) 
twoway (scatter buy suc_attend if fieldday==1 [w=nobs], mcolor(black) msymbol(circle_hollow)) , ///
scheme(s1color) xtitle("Number attending") ytitle("Adoption rate") legend(off) name(buy_bl, replace)
twoway (scatter score suc_attend if fieldday==1 [w=nobs], mcolor(black) msymbol(circle_hollow)) , ///
scheme(s1color) xtitle("Number attending") ytitle("Knowledge score") legend(off) name(score_br, replace)
restore 

graph combine buy_tl buy_bl score_tr score_br, scheme(s1color) iscale(0.6)
graph export "${latex}figure4.pdf", as(pdf) replace

















